package com.c2b.algorithm.newcoder;

/**
 * <a href='https://www.nowcoder.com/practice/c087914fae584da886a0091e877f2c79?tpId=295&tqId=23286&ru=%2Fexam%2Foj&qru=%2Fta%2Fformat-top101%2Fquestion-ranking&sourceUrl=%2Fexam%2Foj'>BM15 删除有序链表中重复的元素-I </a>
 *
 * @author c2b
 * @since 2024/3/14 11:49
 */
public class BM15DeleteDuplicates {
    public static class Solution {
        public ListNode deleteDuplicates (ListNode head) {
            if (head == null) {
                return null;
            }
            ListNode currNode = head;
            while (currNode.next != null) {
                if (currNode.val == currNode.next.val) {
                    currNode.next = currNode.next.next;
                } else {
                    currNode = currNode.next;
                }
            }
            return head;
        }
    }
}
